X

Node.js

Ejs, Render Pages & Pass Data to the View

April 9, 2022

/*

Rendering Pages


*/

With ejs, the render method will automatically look in the views directory for the file.

The ejs render method

Files in the views folder need to have the ejs extension.

/*

Passing Data to the View


*/

You can pass data to the view with ejs. The second argument of the render method takes an object with the data you want to pass to the view.

Passing data to the render method

If the property is an object & they have the same name, you can just pass that name.

Using the same name for the property & the object.

About the Author

Christopher Howard

Chris is a Javascript developer with a minor in UI design. He values programming in vanilla code. Fill out the form below to contact him.